import java.util.Scanner;

/**
 * Created by forcht on 2018/4/23.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int[] a=new int[n];
        int[] dp=new int[n];
        for(int i=0;i<n;i++){
            a[i]=scanner.nextInt();
        }
        dp[n-1]=1;
        for(int i=n-2;i>=0;i--){
            if(i+a[i]>n){
                dp[i]=1;
            }
            else if(a[i]==0){
                dp[i]=Integer.MAX_VALUE;
            }else {
                int min=Integer.MAX_VALUE;
                for(int j=1;j<=a[i]&&i+j<n;j++){
                    if(min>dp[j+i]){
                        min=dp[j+i];
                    }
                }
                dp[i]=(min==Integer.MAX_VALUE?min:min+1);
            }
        }
        if(dp[0]==Integer.MAX_VALUE){
            System.out.println(-1);
        }else {
            System.out.println(dp[0]);
        }
    }
}
